<?php
/**
 * 
 * IndexAction.class.php (前台首页)
 *
 * @package      	jgsat
 * @author          liuxun QQ:147613338 <admin@jgsat.cn>
 * @copyright     	Copyright (c) 2008-2011  (http://www.jgsat.com)
 * @license         http://www.jgsat.com/license.txt
 * @version        	jgsat企业网站管理系统 v2.1 2011-03-01 jgsat.cn $
 */
if(!defined("JGsat")) exit("Access Denied");
class YuyueAction extends BaseAction
{

  
    public function index($catid='',$module='')
    {

		$url_s='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

		$this->assign('url_s',$url_s);

        $this->Urlrule =F('Urlrule');
		if(empty($catid)) $catid =  intval($_REQUEST['id']);

		$p= max(intval($_REQUEST[C('VAR_PAGE')]),1);
		if($catid){
			$cat = $this->categorys[$catid];

			$bcid = explode(",",$cat['arrparentid']); 
                        $jgbcid = $bcid; 
			$bcid = $bcid[1]; 
			if($bcid == '') $bcid=intval($catid);
			if(empty($module))$module=$cat['module'];
			$this->assign('module_name',$module);
			unset($cat['id']);
			$this->assign($cat);
			$cat['id']=$catid;
			$this->assign('jgbcid',$jgbcid);
			$this->assign('catid',$catid);
			$this->assign('bcid',$bcid);
		}
		if($cat['readgroup'] && $this->_groupid!=1 && !in_array($this->_groupid,explode(',',$cat['readgroup']))){$this->assign('jumpUrl',URL('User-Login/index'));$this->error (L('NO_READ'));}
		$fields = F($this->mod[$module].'_Field');
		foreach($fields as $key=>$r){
			$fields[$key]['setup'] =string2array($fields[$key]['setup']);
		}
		$this->assign ( 'fields', $fields); 


		$seo_title = $cat['title'] ? $cat['title'] : $cat['catname'];
		$this->assign ('seo_title',$seo_title);
		$this->assign ('seo_keywords',$cat['keywords']);
		$this->assign ('seo_description',$cat['description']);
				
 
			if($catid){
				$seo_title = $cat['title'] ? $cat['title'] : $cat['catname'];
				$this->assign ('seo_title',$seo_title);
				$this->assign ('seo_keywords',$cat['keywords']);
				$this->assign ('seo_description',$cat['description']);
				

				$where = "groupid=1";


				$itemType=$_GET['itemType'];
				$charge=$_GET['charge'];
				$area=$_GET['city'];

				if($area){
					if(is_numeric($area) == false){
						$ar=M('Area')->where("name='".$area."'")->find();
						$area=$ar['id'];
					}

					$where .= " and (city=".$area." or province=".$area.")";
				}
				if($itemType){
					//$where .= "  and itemType=".$itemType;
					$where .= "  and find_in_set('$itemType', `itemType`)";
				}else{
                    $where .= "  and find_in_set('75', `itemType`)";
				}
                if($charge){

					$where .= " and charge=".$charge;
				}
				// echo $where;exit;
				if(empty($cat['listtype'])){
					$this->dao= M('User');
					$count = $this->dao->where($where)->count();
					//echo $this->dao->getLastSql();exit;

					if($count){
						import ( "@.ORG.Page" );
						$listRows =  !empty($cat['pagesize']) ? $cat['pagesize'] : C('PAGE_LISTROWS');
						$page = new Page ( $count, $listRows );
						$page->urlrule = geturl($cat,'',$this->Urlrule);

						$pages = $page->preshow();
						$field = 'id,avatar,realname,username,my_introduce,province,city,yuyue_num,itemType,case_num,charge';
						$order='listorder asc,createtime desc,id desc';
						if($_GET['order']){
							$order=$_GET['order'].' desc';
						}

						$list = $this->dao->field($field)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select();
						//echo $this->dao->getLastSql();exit;
						//print_r($list);exit;
						$list_d = $this->dao->field($field)->where('pos_hot=1 and groupid=1')->limit(4)->select();
						//print_r($list_d);exit;
						$this->assign('list_d',$list_d);
						$this->assign('pages',$pages);
						$this->assign('list',$list);
					}
					$template_r = 'list';
				}else{
					$template_r = 'index';
				}
			}else{
				$template_r = 'list';
			}
			$template = $cat['template_list'] ? $cat['template_list'] : $template_r;

             //城市
		    $bcity_hot=M("Area")->field("*")->where("hot=1 ")->order("listorder asc")->limit("50")->select();
		    $this->assign('bcity_hot', $bcity_hot);


			$this->display($module.':'.$template);
		}


	public function show($id='',$module='')
	{
		$this->Urlrule =F('Urlrule');

		$id = $id ? $id : intval($_REQUEST['id']);

		$this->dao= M('User');
		$data = $this->dao->find($id);






		$this->assign ($data);
      // print_r($data);exit;
		$this->display();
	}


   
 
 
}
?>